# daca iti baga faze cu "no rule to make..." inseamna k ai gresit ceva prin _DEPS sau _SRCS
#.SUFFIXES: .c .cpp

SDIR = ./src/
IDIR = ./include/

INCLUDE = -I$(IDIR) -I../lib/lua/src/ -I../lib/tinyxml/src/

CC = g++

ifeq	($(DEBUG),1)
	DEFINES = -DDEBUG -D_DEBUG -DLINUX -O0 -ggdb
	ODIR = ./build/Linux/Debug
else
	DEFINES = -DLINUX -DNDEBUG -O2
	ODIR = ./build/Linux/Release
endif

CFLAGS = -Wall $(DEFINES) $(INCLUDE)

_SRCS = Config.cpp glInfo.cpp Timer.cpp File/File.cpp File/LocalFile.cpp Shader/GPUProgram.cpp Shader/CgProgram.cpp Shader/GLSLProgram.cpp Shader/ShaderManager.cpp Texture/Texture.cpp Texture/TGATextureLoader.cpp Texture/ITextureLoader.cpp Texture/TextureManager.cpp Util.cpp Input/InputManager.cpp Model/Mesh.cpp Model/MeshManager.cpp Model/VertexBuffer.cpp Model/VertexIndexBuffer.cpp Scene/Camera/Camera.cpp Scene/Mover.cpp Scene/Object.cpp Scene/SceneManager.cpp Scene/IObjectLoader.cpp Scene/ObjectLoaders/OBJObjectLoader.cpp Scene/ObjectLoaders/MS3DObjectLoader.cpp Material/Material.cpp Material/MaterialManager.cpp Profiling/ProfilingManager.cpp Scene/Culling/AABBox.cpp Scene/Culling/Frustum.cpp Scene/Culling/Plane.cpp Scene/Culling/DefaultCuller.cpp Scene/Culling/FrustumCuller.cpp Scripting/Script.cpp Scripting/ScriptManager.cpp UI/Container.cpp UI/UIManager.cpp Math/Matrix4x4.cpp Math/Vec2f.cpp Math/Vec3f.cpp Scene/Culling/Sphere.cpp
_OBJS = $(_SRCS:.cpp=.o)
_DEPS = Cg/cgGL.h Cg/cg.h GL/glew.h GL/glext.h GL/glut.h GL/glxew.h MGL_config.h Config.h glInfo.h Timer.h MGLib.h AbstractManager.h Application.h File/File.h File/LocalFile.h Shader/GPUProgram.h Shader/CgProgram.h Shader/GLSLProgram.h Shader/ShaderManager.h Texture/Texture.h Texture/TGATextureLoader.h Texture/ITextureLoader.h Texture/TextureManager.h Util.h Input/InputManager.h Model/Mesh.h Model/MeshManager.h Model/VertexBuffer.h Model/VertexIndexBuffer.h Scene/Camera/Camera.h Scene/Mover.h Scene/Object.h Scene/SceneManager.h Scene/IObjectLoader.h Scene/ObjectLoaders/OBJObjectLoader.h Scene/ObjectLoaders/MS3DObjectLoader.h Material/Material.h Material/MaterialManager.h Profiling/ProfilingManager.h Scene/Culling/AABBox.h Scene/Culling/Frustum.h Scene/Culling/Plane.h Scene/Culling/Culler.h Scene/Culling/DefaultCuller.h Scene/Culling/FrustumCuller.h Scripting/Script.h Scripting/ScriptManager.h UI/Container.h UI/UIManager.h Math/Matrix4x4.h Math/Vec2f.h Math/Vec3f.h Scene/Culling/Sphere.h

SRCS = $(patsubst %,$(SDIR)/%,$(_SRCS))
OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))

PRJ = $(ODIR)/libMGLib.a


build:	build-path	all

all:	$(PRJ)

$(PRJ):	$(OBJS)
	ar rcs $@ $^

$(ODIR)/%.o:	$(SDIR)/%.cpp	$(DEPS)
	mkdir -p `dirname $@` 2>/dev/null
	$(CC) -c $< -o $@ $(CFLAGS)

build-path:	$(ODIR)

$(ODIR):
	mkdir -p $(ODIR)

.PHONY:	clean
	
clean:	clean-edits
	rm -fr $(ODIR)

clean-edits:
	#rm -fr $(find . -name *~)
	
rebuild:	clean	all

